package com.qf.Interceptors;

import com.qf.cache.MenuCache;
import com.qf.pojo.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
杨威
2022/1/9
17:44
*/
@Component
public class ApiCheckInter implements HandlerInterceptor {
    @Autowired
    private MenuCache menuCache;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String uri = request.getRequestURI();
        Menu menu = menuCache.getMenuByUrl(uri);

        return "1".equals(menu.getEnable());
    }
}
